
#include "apue.h"
#include <termios.h>

int main()
{
    struct termios term;

    if (tcgetattr(STDIN_FILENO, &term) < 0)
    {
        err_sys("tcgetattr error");
    }

    switch (term.c_cflag & CSIZE)
    {
        case CS5:
        {
            printf("5 bit/byte\n");
            break;
        }
        case CS6:
        {
            printf("6 bit/byte\n");
            break;
        }
        case CS7:
        {
            printf("7 bit/byte\n");
            break;
        }
        case CS8:
        {
            printf("8 bit/byte\n");
            break;
        }
        default:
        {
            printf("unknow bits/byte\n");
            break;
        }
    }

    term.c_cflag &= ~CSIZE;
    term.c_cflag |= CS8;
    if (tcsetattr(STDIN_FILENO, TCSANOW, &term) < 0)
    {
        err_sys("tcsetattr error");
    }

    exit(0);
}
